package com.dailyblue.java.spring.boot.redis.controller;

import com.dailyblue.java.spring.boot.redis.bean.Emp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/obj")
@Slf4j
public class ObjectRedisController {
    @Resource
    private RedisTemplate redisTemplate;

    @GetMapping
    public void a() {
        ValueOperations value = redisTemplate.opsForValue();
        Emp emp = new Emp();
        emp.setEname("amdin");
        value.set("A", emp);
        Object obj = value.get("A");
        log.info("obj:{}", obj);
    }
}
